home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Stuff / 3D_Reality / Shaders / Shader_Source / SD_Texture.sl < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.1 KB  |  41 lines

  1. /*************************************************************************
  2. *    Copyright (c) 1989-1992 Stone Design Corp.  All rights reserved. 
  3. *    programmer:    Bill Bumgarner
  4. *    File name:    SD_Texture.sl
  5. *    Date:        Jul 21 1992 
  6. *    Purpose:    The simplest of textures w/lighting cues...
  7.  
  8.     Variables:
  9.         txmap:        full path to the texture map file
  10.  
  11.         Ka:            percentage of ambient light used
  12.         Kd:            percentage of diffuse light used
  13.         Ks:            specular highlight intensity
  14.         roughness:        the roughness/smoothness (reflectivity) of
  15.                     of the surface-- very noticeable effect on the
  16.                 specular highlight
  17.         specularcolor:    color used in the specular highlight
  18. ***************************************************************************/
  19.  
  20. surface SD_Texture(
  21.     string    txmap        = "";
  22.  
  23.     float     Ka        =  1,
  24.         Kd        = .5,
  25.         Ks        = .5,
  26.         roughness    = .1;
  27.     color    specularcolor    = 1;
  28. )
  29. {
  30.     point Nf = faceforward(N, I);
  31.     
  32.  
  33.     if(txmap != ""){
  34.         Ci = color texture(txmap, s, t);
  35.     } else {
  36.         Ci = Cs;
  37.     }
  38.     Oi = Os;
  39.     Ci=Os * (Ci * (Ka*ambient() + Kd*diffuse(Nf)) + 
  40.             specularcolor * Ks * specular(Nf,-I,roughness));
  41. }